/**
 * @file STL_Timestamp.h
 * @author Derek Liu (yjkhtddx@sina.com)
 * @brief 
 * @version 0.1
 * @date 2020-09-10
 * 
 * @copyright Copyright Sci-Tech Laboratories (c) 2020
 * 
 */

#ifndef _STL_TIMESTAMP_H_
#define _STL_TIMESTAMP_H_

#include "STL_Tools.h"
#include <string>

/*
 
 format 参考：http://www.cplusplus.com/reference/ctime/strftime/
 额外增加 "%s" 表示毫秒时间
 
 例子
 "%Y"     ==>     2017-01-07 18:30:30 248
 
 日期
 "%F"     ==>     2017-01-07
 "%D"     ==>     01/07/17
 "%c"     ==>     Sat Jan  7 18:30:30 2017
 年
 "%y"     ==>     17
 "%Y"     ==>     2017
 月
 "%m"     ==>     01
 "%b"     ==>     Jan
 "%B"     ==>     January
 星期
 "%u"     ==>     6
 "%w"     ==>     6
 "%a"     ==>     Sat
 "%A"     ==>     Saturday
 日
 "%d"     ==>     07
 "%e"     ==>     7
 时间
 "%T"     ==>     18:30:30
 "%X"     ==>     18:30:30
 "%r"     ==>     06:30:30 PM
 "%R"     ==>     18:30
 时
 "%H"     ==>     18
 "%I"     ==>     06
 "%p"     ==>     PM
 分
 "%M"     ==>     30
 秒
 "%S"     ==>     30
 毫秒
 "%s"     ==>     249
 
 */

namespace STL
{
    void printfTimestamp(const char *file, int line, const char *function, const char *title);
    long getTimestamp(long offset = 0);
    long long getMillTimestamp(long long offset = 0);
    std::string getTimestampString();
    std::string getTimestampString(std::string format);
    std::string getTimestampString(std::string format, long timestmap);
    std::string getTimestampString(std::string format, long long millTimestamp);
    long getTimestampFromTime(std::string time);//2021-9-27 19:57:05
}

#define stlog_timestamp(title) (STL::printfTimestamp(__FILE__, __LINE__, __FUNCTION__, title))

#endif /* _STL_TIMESTAMP_H_ */
